package com.zf.experiment.controller;

import com.zf.common.core.result.RestResponse;
import com.zf.experiment.annotation.AopAccessLimit;
import com.zf.experiment.annotation.InterceptorAccessLimit;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author Zhou Feng
 */
@RestController
public class HelloController {

    @AopAccessLimit(seconds = 10, maxCount = 1)
    @GetMapping("/hello")
    public RestResponse<?> hello(){
        HashMap<String, Object> res = new HashMap<>();
        res.put("name", "hello world");
        res.put("id", 123L);
        return RestResponse.success(res);
    }


    @InterceptorAccessLimit(seconds = 10, maxCount = 1)
    @GetMapping("/test")
    public RestResponse<?> test(){
        HashMap<String, Object> res = new HashMap<>();
        res.put("name", "hello test");
        res.put("id", 123L);
        return RestResponse.success(res);
    }


    @GetMapping("/test2")
    public RestResponse<?> test2(){
        HashMap<String, Object> res = new HashMap<>();
        res.put("name", "hello test2");
        res.put("id", 123L);
        return RestResponse.success(res);
    }


}
